package fs.cypher {
	import flash.utils.Dictionary;
	import flash.utils.getDefinitionByName;
	/**
	 * ...
	 * @author flyingSnow
	 */
	public class Monoalphabetic {
		
		public static function encrypt(plainText:String,
						sourceString:String = "abcdefghijklmnopqrstuvwxyz",
						key:String = "hijklmbctuvfrswgynazopqxde"):String {
			var dicSource:Dictionary = new Dictionary();
			var i:int = 0;
			for (i = 0; i < sourceString.length; i++ ) {
				dicSource[sourceString.charAt(i)] = key.charAt(i);
			}
			
			var arrResult:Array = [];
			for (i = 0; i < plainText.length; i++ ) {
				arrResult.push(dicSource[plainText.charAt(i)]);
			}
			return arrResult.join("");
		}
		public static function decrypt(cipherText:String,
						sourceString:String = "abcdefghijklmnopqrstuvwxyz",
						key:String = "hijklmbctuvfrswgynazopqxde"):String {						
			return encrypt(cipherText,key,sourceString);
		}
	}

}